<html>
<head>
    <title>Grid mode</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <script type="text/javascript" src="vault.js?v=3.0.0"></script>
    <link rel="stylesheet" type="text/css" href="vault.css?v=3.0.0">

</head>
<body>
<div id="test" class="container"></div>

<script>
    var _GET = new Array();
    var u = window.location.toString();
    u = u.split('?');
    if (typeof(u[1]) == 'string') {
        u = u[1].split('&');
        for (i = 0; i < u.length; i++) {
            s = u[i].split("=");
            eval('_GET["' + s[0] + '"]' + '="' + decodeURIComponent(s[1]) + '"');
        }
    }
    var targetUrl = _GET['uploadUrl'];
    if (targetUrl == null) {
        alert("上传地址不能为空！");

    }
    var params = {};
    for (key in _GET) {

        if (key && key != "uploadUrl" && _GET[key]) {
            params[key] = _GET[key];
            //alert(  params[key]+  _GET[key]);
        }
    }

    //alert(targetUrl);


    var vault = new dhx.Vault('vault', {
        mode: "grid",

        uploader: {
            target: targetUrl,
            autosend: false,
            params: params
        }
    });

    try {
        if (filter && filter.indexOf(";") > -1) {
            var filters = filter.split(";");
            vault.events.on("beforeAdd", function (item) {
                var extension = item.file.name.split(".").pop();
                var size = item.file.size;
                for (var i = 0; i < filters.length; i++) {
                    if (extension == filters[i]) {
                        return true;
                    }
                    ;
                }
                return false;
            });

            vault.events.on("uploadcomplete", function (item) {

                try {

                    var data = {
                        eventType: 'uploadcomplete',
                        item: _this._uploadInfo.files[0].file,
                        response: request.response

                    }
                    parent.postMessage(data)


                } catch (e) {
                    console.log(e);

                }
            });


        }
    } catch (e) {

    }


    // vault.data.parse(filesData);

</script>
</body>
</html>